let arr = [1, 10, 2, 21, 29, 3]

function fn(arr) {
    if (arr.length === 0) return ''
    for (var i = 0, len = arr.length; i < len; i++) {
        for (var j = 0; j < len; j++) {
            var a = parseInt(arr[i] + '' + arr[j]),
                b = parseInt(arr[j] + '' + arr[i])
            if (a > b) {
                var tmp = arr[i];
                arr[i] = arr[j];
                arr[j] = tmp;
            }
        }
    }
    return arr;
}
console.log(fn(arr))